var app = getApp();

Page({
  data: {
    flag: true,
    money: '',
    amount: '',
    //account: ''
  },
  onShow: function () {
    var that = this;
    that.getData();
  },
  getData: function () {
    var that = this;
    app.JsonPost("Api/User/index", {}, function (res) {
      //console.log(res);
      that.setData({
        money: res.money
      })
    });
  },
  amountTap: function(e) {
    this.setData({
      amount: e.detail.value
    })
  },
  accountTap: function(e) {
    this.setData({
      account: e.detail.value
    })
  },
  wstCash: function(options) {
    var that = this;
    //判断是否输入提现金额
    if (that.data.amount == '') {
      wx.showModal({
        title: '提示',
        content: '请输入提现金额!',
        showCancel: false,
        success: function(res) {}
      });
      return false;
    }

    //判断是否输入提现账户
    // if (that.data.account == '') {
    //   wx.showModal({
    //     title: '提示',
    //     content: '请输入提现账户!',
    //     showCancel: false,
    //     success: function(res) {}
    //   });
    //   return false;
    // }

    var jsonData = {
      money: that.data.amount,
      //account: that.data.account
    };
    app.showLoading("正在提交...请稍后...");
    app.JsonPost("Api/Money/create", jsonData, function(data) {
      console.log(data);
      app.closeLoading();
      if (data !== false) {
        wx.showModal({
          title: '提示',
          content: '提交成功!',
          showCancel: false,
          success: function(res) {
            that.setData({
              //amount: '',
              account: '',
              flag: true
            });
            that.onLoad();
          }
        });
      }
    })
  },
  wstCashRecord: function(options) {
    wx.navigateTo({
      url: "wstCashRecord"
    })
  },
  showPop: function() {
    this.setData({
      flag: false
    })
  },
  hidePop: function() {
    this.setData({
      flag: true
    })
  }
})